package com.platform.util;

/**
 * Created by Administrator on 2018/4/20 0020.
 */
public class StringUtil {
    public static String valueOfString(Object o){
        if(null != o){
            try{
                return String.valueOf(o);
            }catch (Exception e){
                return "";
            }
        }else{
            return "";
        }
    }

    public static String valueOfString(Object o,String defaultValue){
        if(null != o){
            try{
                return String.valueOf(o);
            }catch (Exception e){
                return defaultValue;
            }
        }else{
            return defaultValue;
        }
    }

    /**
     * 判断字符为空
     * @param o
     * @return
     */
    public static boolean isEmpty(Object o){
        boolean flag = false;
        if(null == o || "".equals(valueOfString(o))){
            flag = true;
        }
        return flag;
    }

    /**
     * 判断字符不为空
     * @param o
     * @return
     */
    public static boolean isNotEmpty(Object o){
        boolean flag = false;
        if(null != o && !"".equals(valueOfString(o))){
            flag = true;
        }
        return flag;
    }

}
